﻿<ResourceDictionary x:Class="OpenLS.Spreadsheet.UI.DataValidationResources"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Spreadsheet="clr-namespace:OpenLS.Spreadsheet;assembly=OpenLS.Spreadsheet" xmlns:Internals="clr-namespace:OpenLS.Spreadsheet.UI.Internals" xmlns:UI="clr-namespace:OpenLS.Spreadsheet.UI" xmlns:Internals1="clr-namespace:OpenLS.Chart.UI.Internals;assembly=OpenLS.Chart.UI"
                    xmlns:Resources="clr-namespace:OpenLS.Spreadsheet.UI.Internals.Resources">
    <ResourceDictionary.MergedDictionaries>
        <UI:EnumResources></UI:EnumResources>
    </ResourceDictionary.MergedDictionaries>

    <DataTemplate DataType="{x:Type UI:DataValidationViewModel}">
        <TabControl>
            <TabItem Header="{x:Static Resources:UIStringTable.Settings}">
                <GroupBox Header="{x:Static Resources:UIStringTable.ValidationCriteria}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition Height="Auto"></RowDefinition>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>
                        <TextBlock Text="{x:Static Resources:UIStringTable.Allow}"></TextBlock>
                        <ComboBox Grid.Row="1" SelectedItem="{Binding Type}" ItemsSource="{Binding Source={x:Type Spreadsheet:DataValidationType}, Converter={x:Static Internals1:ChartConverters.EnumEnumerator}}"></ComboBox>
                        <TextBlock Text="{x:Static Resources:UIStringTable.Data}" Grid.Row="2"></TextBlock>
                        <ComboBox Name="operator" Grid.Row="3" SelectedItem="{Binding Operator}" 
                                  ItemsSource="{Binding Source={x:Type Spreadsheet:DataValidationOperator}, Converter={x:Static Internals1:ChartConverters.EnumEnumerator}}"></ComboBox>
                        <Label Name="firstFormulaLabel" Visibility="{Binding ElementName=firstFormula, Path=Visibility}" Grid.Row="4" Content="{Binding FirstFormulaLabel}"></Label>
                        <TextBox Name="firstFormula"  Grid.Row="5" Grid.ColumnSpan="2" Text="{Binding Model.Formula1}"></TextBox>
                        <Label Name="secondFormulaLabel" Visibility="{Binding ElementName=secondFormula, Path=Visibility}"  Grid.Row="6" Content="{Binding SecondFormulaLabel}"></Label>
                        <TextBox Name="secondFormula"  Grid.Row="7" Grid.ColumnSpan="2" Text="{Binding Model.Formula2}"></TextBox>


                    </Grid>
                </GroupBox>
            </TabItem>
            <TabItem Header="{x:Static Resources:UIStringTable.InputMessage}">
                <StackPanel>
                    <CheckBox IsChecked="{Binding Model.ShowInputMessage}" Content="{x:Static Resources:UIStringTable.ShowInputMessageWhenCellIsSelected}"></CheckBox>
                    <Label Content="{x:Static Resources:UIStringTable.WhenCellIsSelectedShowThisInputMessage}"></Label>
                    <Label Content="{x:Static Resources:UIStringTable.Title_}"></Label>
                    <TextBox Text="{Binding Model.PromptTitle}"></TextBox>
                    <Label Content="{x:Static Resources:UIStringTable.InputMessage_}"></Label>
                    <TextBox Text="{Binding Model.Prompt}"></TextBox>
                </StackPanel>
            </TabItem>
            <TabItem Header="{x:Static Resources:UIStringTable.ErrorAlert}">
                <StackPanel>
                    <CheckBox IsChecked="{Binding Model.ShowInputMessage}" Content="{x:Static Resources:UIStringTable.ShowErrorAlertAfterInvalidDataIsEntered}"></CheckBox>
                    <Label Content="{x:Static Resources:UIStringTable.WhenUserEntersInvalidDataShowThisErrorAlert}"></Label>
                    <Label Content="{x:Static Resources:UIStringTable.Style_}"></Label>
                    <ComboBox SelectedItem="{Binding Model.ErrorStyle}" ItemsSource="{Binding Source={x:Type Spreadsheet:DataValidationErrorStyle}, Converter={x:Static Internals1:ChartConverters.EnumEnumerator}}"/>
                    <Label Content="{x:Static Resources:UIStringTable.Title_}"></Label>
                    <TextBox Text="{Binding Model.ErrorTitle}"></TextBox>
                    <Label Content="{x:Static Resources:UIStringTable.ErrorMessage_}"></Label>
                    <TextBox Text="{Binding Model.Error}"></TextBox>
                </StackPanel>

            </TabItem>
        </TabControl>
        <DataTemplate.Triggers>
            <DataTrigger Binding="{Binding Type}" Value="{x:Static Spreadsheet:DataValidationType.Custom}">
                <Setter TargetName="operator" Property="IsEnabled" Value="False"></Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding Type}" Value="List">
                <Setter TargetName="operator" Property="IsEnabled" Value="False"></Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding Type}" Value="None">
                <Setter TargetName="operator" Property="IsEnabled" Value="False"></Setter>
                <Setter TargetName="firstFormula" Property="Visibility" Value="Hidden"></Setter>
                <Setter TargetName="secondFormula" Property="Visibility" Value="Hidden"></Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding Operator}" Value="{x:Static Spreadsheet:DataValidationOperator.Equal}">
                <Setter TargetName="secondFormula" Property="Visibility" Value="Hidden"></Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding Operator}" Value="{x:Static Spreadsheet:DataValidationOperator.NotEqual}">
                <Setter TargetName="secondFormula" Property="Visibility" Value="Hidden"></Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding Operator}" Value="{x:Static Spreadsheet:DataValidationOperator.LessThan}">
                <Setter TargetName="secondFormula" Property="Visibility" Value="Hidden"></Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding Operator}" Value="{x:Static Spreadsheet:DataValidationOperator.LessThanOrEqual}">
                <Setter TargetName="secondFormula" Property="Visibility" Value="Hidden"></Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding Operator}" Value="{x:Static Spreadsheet:DataValidationOperator.GreaterThan}">
                <Setter TargetName="secondFormula" Property="Visibility" Value="Hidden"></Setter>
            </DataTrigger>
            <DataTrigger Binding="{Binding Operator}" Value="{x:Static Spreadsheet:DataValidationOperator.GreaterThanOrEqual}">
                <Setter TargetName="secondFormula" Property="Visibility" Value="Hidden"></Setter>
            </DataTrigger>
        </DataTemplate.Triggers>
    </DataTemplate>
</ResourceDictionary>
